home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 1
/
Gold Medal Software Volume 1 (Gold Medal) (1994).iso
/
menuts
/
batmouse.arj
/
BATMOUSE.TXT
< prev
next >
Wrap
Text File
|
1993-08-22
|
21KB
|
386 lines
INTRODUCING "BATMOUSE" - A MOUSE FOR YOUR BATCH FILES
Have you ever wondered what makes a batch file seem slow at times
or have you tried to write a batch file and given up in
frustration? Did you ever think you might like to have multiple
batch file menus or to interface your batch file with keyboard
responses? Better yet, interact with your mouse? Read on.
If you use DOS programs exclusively or if you use Windows and
occasionally need to go to DOS to use some other program.
BATMOUSE and DIRECTOR.BAT provide a means to display a
sophisticated menu from within a batch file and are completely
compatible with all programs. You may invoke Windows from
DIRECTOR.BAT and exit Windows temporarily to DIRECTOR.BAT,
execute an otherwise Windows compatible program, return to the
DIRECTOR and then return to Windows - no problem.
DOS dos not have a good reputation for user friendliness, and the
batch file interpreter is not much better. That's why there are
many programs around that will help you interface with your batch
files - programs like BATMOUSE and DIRECTOR.BAT.
DIRECTOR.BAT is an accumulation of ideas for batch files that
ultimately led to the development of the mouse interface program
BATMOUSE. Simply put, BATMOUSE is a standalone program that may
be called from any batch file or from DOS; it causes the mouse
cursor to appear seamlessly and reacts to any keyboard input and
to the movements/clicks of your mouse.
Communications between any batch file and BATMOUSE are conducted
via the environment variables HR & VC (for horizontal row &
vertical column) for a mouse click and the testing of ERRORLEVEL
for the last key pressed.
BATMOUSE checks the environment for variables HR & VC in order to
set the mouse position to that which was clicked on the during
the last execution of the program, if there was one. This is
performed at startup unless the environment variables have not
been previously set or have been set to a "-", in which case the
mouse appears in the center of the screen. BATMOUSE always sets
HR & VC to a "-" when the user presses a key instead of a mouse
button. This allows the batch file to discern which kind of
interpretation to make - mouse coordinate or key press. If
either HR or VC = "-", the user last pressed a key. Mouse screen
coordinates are 1,1 for the upper left corner and 25,80 (HR,VC
respectively) for the lower right corner.
The DIRECTOR batch file may be used with or without a mouse.
However, one of its greatest features is the integration of the
mouse interface program BATMOUSE. Used without a mouse,
DIRECTOR.BAT requires the use of a program available on most
bulletin boards called REPLY.COM or KEYPRESS.COM. They have been
described in numerous magazine articles and will not be discussed
here. If you are currently using one of these programs with your
batch files, your existing batch file should work seamlessly with
BATMOUSE since the key values returned are identical.
A complete listing of DIRECTOR.BAT with line reference numbers is
found in file DIRECTOR.TXT. The line sequence numbers found in
the left column of this listing are provided in order to
understand the following references to the descriptions of its
functions and should be removed if you plan to use this example
to create your own batch file.
DIRECTOR.BAT is sensitive to seven parameters (%1 %2 %3 %4 %5 %6
%7). If you do not pass parameters the defaults of black and
white are used. This allows you to pass only as many parameters
as you require - if you pass only parameter one, a particular
background screen will be painted and all the text will be white
on black. The program SHOW (line 211) will paint any of 17
predefined background screens - the screen names are DIRSCN (B&W
or default use) and DIRSCN00-DIRSCN15 (various color
combinations). Therefore, if parameter one (%1) contains 00 or
01 or 02 ∙∙∙∙ 15, the corresponding screen will be displayed;
hence, SHOW DIRSCN%1.
The remaining six parameters are used to paint certain text
portions of the menu:
- %2 & %3 (foreground/background) are used to paint your
personal menu title.
- %4 & %5 (foreground/background) are used to paint the
function key information.
- %6 & %7 (foreground/background) are used to paint the
program names at each line of the menu and the menu
page number.
Each of the above color parameters may be created using the color
combinations for foreground and background. The following
information is derived from the documentation for ANSI.SYS:
Foreground Colors:
30 - Black
31 - Red
32 - Green
33 - Yellow (which is brown unless BOLD is on)
34 - Blue
35 - Magenta
36 - Cyan
37 - White
Background Colors (bold does not affect these colors):
40 - Black
41 - Red
42 - Green
43 - Brown
44 - Blue
45 - Magenta
46 - Cyan
47 - White
Try some of the following calls to the DIRECTOR:
%1 %2 %3 %4 %5 %6 %7
DIRECTOR 00 33 44 37 47 37 44
DIRECTOR 00 33 46 37 47 37 44
DIRECTOR 06 33 37 37 47 37 41
DIRECTOR 08 33 47 37 47 37 41
DIRECTOR 08 33 40 37 47 37 41
Also, be sure to type DEMO to see all the background screens and
some of the possible color combinations.
Let's begin our analysis of DIRECTOR.BAT with line 2; this line
allows the DIRECTOR to be aware that the current state of the
screen is unknown and should be repainted completely. Line 3 is
required if you have more than one menu screen to display (we are
dealing with 3). If the condition is true, it is implied that
the environment variable %MENU% is equal to something other than
'x' and therefore has been previously used; ie, the batch file
is returning from a DOS based call or from an exit to DOS and the
subsequent call of DIRECTOR. It then branches to the MAINMENU
label found on line 24 where the screen is then completely
repainted (line 28) and the appropriate program menu is displayed
based on %MENU% (in this case 1, 2 or 3). DIRECTOR always
returns from DOS and presents the last menu or menu 1 if this is
the first time in.
Upon return from a calling program or calling DIRECTOR from the
command line, note that line 2 sets the variable SCRN to 'on'
(case sensitive). This causes line 28 to branch (GOTO) to the
SCN label (line 207) which causes the screen to be painted with a
predefined screen (line 211). The program SHOW on this line will
paint any of 17 predefined screens as discussed above.
The use of lines 209 through 225 require some understanding of
the use of ANSI.SYS - the DOS 5.0 manual (pages 593-599) provide
an in depth review which is not possible here. An overview of
those lines follows:
Line 209 - Sets the cursor position to the upper left
corner or position (0,0) which is not the same as
BATMOUSE (1,1). Testing of this feature suggests that
both 0,0 and 1,1 paint from the upper left corner
(contrary to the Microsoft documention) while it is
implied that 1,1 is below and to the right 1 character.
Line 210 - Clears the line to the right of the current
cursor position.
Line 211 - Shows a screen as described above.
Line 212 - Sets up a bold color combination based on
parameters 2 and 3; hence %2 and %3. The 1 on the left
determines bold which only affects the foreground
color.
Line 213 - Paints text (with the color from line 212) at
screen line 3, column 2 - don't hesitate to change the
text to something more suitable.
Line 214 - Sets up a bold color combination (used with
lines 215-225) based on parameters 4 and 5; hence %4
and %5. The 1 on the left determines bold.
Line 226 - Causes a branch (GOTO) to %menu% (either 1
(line 30), 2 (line 42) or 3 (line 54)) where the
specific menu items for the current menu page are
painted (lines 30-65) using parameters 6 and 7. The
program references contained in these lines should be
modified to support the needs of the user. Control is
the passed to line 65 (ENDSCR) where the color is set
to white on black (line 66), the cursor turned on (line
67) and BATMOUSE is called (line 69) and the user must
click a mouse button or press an appropriated key.
If you use a lot of remarks in your batch file you will find that
your batch files will execute much faster if you place statements
to branch (GOTO) around them as found on line 4. A first time
call on DIRECTOR branches to MENU1 where MENU is set to 1 and
control is passed to MAINMENU on line 24.
The lines from 8 to 23 are Page UP & Page DOWN controls and cause
the program to branch based on which menu page is currently being
displayed. The mouse cursor may also be used to invoke this code
if the user clicks the mouse button while the mouse cursor is on
the upper or lower 3 lines of the screen - see lines 90-95.
Lines 90 & 91 test for the top and bottom of the screen
respectively and because they are the most likely lines to be
clicked on, they are placed at the beginning of the tests for
Page UP and Page DOWN - this speeds up the process.
The keyboard keys Page UP & Page DOWN return codes in ERRORLEVEL
that conflict with the codes for "I" & "Q" respectively, and
therefore are not used in this example. There is no reason not
to use them if you are not also using "I" & "Q"; remember these
keys will be tested as equals to Page UP and Page DOWN. A more
complete list of codes may be found in most technically oriented
program documentation and in the various DOS manuals - see page
632 of the DOS 5.0 manual.
At the MAINMENU label found on line 24, the drive and directory
are immediately set (lines 25 & 26) just in case they were not
reset by a called program or batch file. If you plan to use some
other drive/directory as a base to work from, change line 25/26
appropriately.
Program BATMOUSE (line 69) is called. BATMOUSE then waits for a
mouse or keyboard response, all the while moving the mouse cursor
appropriately.
Line 70 determines whether the user has pressed a key or has
clicked a mouse button. The environment variable VC is tested
for not being a "-" which, if true, would indicate a mouse button
was pressed. If true (ie, not a "-"), DIRECTOR.BAT branches to
the MOUSE label on line 89 where the initial tests for Page UP &
Page DOWN are conducted as described above.
Conversely, if VC contains the value "-" control is passed to the
next line (71 in this case) where the first tests are for the
values 'H' or 'h' for HELP. A brief display of the help screen
(lines 204-206) occurs, the user presses a key or mouse button
and the complete screen is regenerated beginning at line 207.
Immediately following the check for help is a check for the F10
key (line 73) which is a menu item for Page DOWN. Several tests
for an exit to DOS are made (lines 74-77); they test for 'Q',
ESC, F9 and 'q' respectively and cause a branch to F9 (line 227).
The F9 label (EXIT TO DOS) sets up the echo command which causes
a screen clear when line 230 is invoked.
At this point it is likely the user wants to run a program and we
need to prepare for repainting the screen - line 87 makes that
preparation by setting the environment variable SCRN to 'on'
(case sensitive).
Lines 79-86 check which key (F8-F1 respectively) was pressed and
branch accordingly. A discussion of how the 'program' branching
works follows below.
Any other key causes a branch to BADKEY on line 125. Line 126
causes a beep on your PC's speaker. The character that you see
is the ASCII bell character # 7 - it can generally be produced
with your word processor by pressing and holding the ALT key and
then pressing the 7 key on the numeric key pad on the right side
of your keyboard or a special menu found in some of the newer
WINDOWS programs. It is sometimes a non-printable character.
Control then bypasses MAINMENU and branches (line 128) to REENTER
(line 68) where BATMOUSE is called and the process starts again.
Lines 99-113 test for a valid range of VERTICAL COLUMNS (VC)
which may be expanded or reduced to suit one's needs. The test
in this case is for a vertical range because the menu is
presented vertically. A resulting valid test on one of these
lines forces a branch to the the CALLPROG label on line 115 where
tests on HR are performed (lines 117-124).
A true comparison on any one of these tests causes a branch to a
label corresponding to the combination of the key pressed and the
screen (page) being presented.
Look more closely at lines 79-86 (keyboard) and lines 117-124
(mouse); the branch-to location is determined by the
concatenation of two variables. One is a literal that is based
on which key was pressed or which position of the screen was
clicked on with the mouse (in this case F1-F7) and the other is
the value of the environment variable MENU. MENU should only be
set by DIRECTOR.BAT and must be 1, 2 or 3 unless you are adding
more pages to the menu. Therefore, all program call labels in
the menus are named "Fnn" (lines 129 to 203). Line 129 ("F11")
represents key F1 pressed/selected from menu page 1 while line
197 ("F73") represents key F7 pressed/selected from menu page 3.
There are three ways of setting up the call of a menu program
selection; 1) use CALL to execute batch files (call is not
required if a batch file call is the last line in the calling
batch file) from within a batch file (line 189); 2) use the
program name directly (line 187) or; 3) use SET
PROGTODO=<program name or batch file name> and exit DIRECTOR via
the GOTO END (lines 178-179). Note that the label END does not
clear the screen which makes for a more seamless transition to
your program. Be sure to set the appropriate directory when
required; either in-line (line 156) or in your external batch
files. External batch files called from the DIRECTOR should not
call the DIRECTOR while those that are invoked using the PROGTODO
mechanism should call DIRECTOR as the last statement (command)
and should not use the CALL option. Use the statement DIRECTOR.
Some discussion as to how the PROGTODO mechanism (line 230)
functions is in order. Since the command is not one of the
internal batch file commands it is interpreted to be an external
file name and since it is enclosed in %∙∙∙∙%, the batch file
intepreter will first determine the contents of %PROGTODO%.
Therefore, upon exit from DIRECTOR, DOS will invoke the contents
of PROGTODO.
Suppose you want to install your first program in DIRECTOR.BAT
and that you want to use the empty line F8 on menu page 1 for
that purpose.
It would be beneficial to have a copy of DIRECTOR.TXT
(DIRECTOR.BAT with line reference numbers). From the DOS command
line type the following: COPY DIRECTOR.TXT LPT1
That should print a copy of DIRECTOR.TXT on the printer connected
to the default printer port of your PC.
The following steps will assist you in converting DIRECTOR.BAT to
meet your personal requirements (make sure overtype is on or
insert is off on your word processor):
∙ Consider changing the text
P E R S O N A L D I R E C T O R on line 213 to
something like your company name or
"J O H N'S D I R E C T O R".
∙ Review the text beginning at line 30 thru line 39.
These are the lines that represent the specific program
displays of menu page one. Line 32 represents F1 and
line 39 represents F8. Be aware that there are
trailing spaces beyond the program reference - some
word processors do not display the line feed/carriage
returns found at the end of the all lines in ASCII
files. The idea here is to avoid affecting the
alignment of the spaces which provide an on screen
visual organization.
∙ Insert the text you want to display on screen beginning
on line 39 just under the 'P' in 'PAINT BRUSH'.
∙ Note that the label (line 150) for this menu page and
F-KEY is F81. As discussed above, F8 is for the key F8
and 1 is for menu page 1. Just after line 150 and
before line 151 you must insert at least one if not
more lines. This can be done with most word processors
by turning on insert (overtype is off), placing the
cursor at the beginning of line 151 and pressing
<enter> once for each new line to be inserted. Note,
this will forever change the line references in
DIRECTOR.BAT, however, you may still use DIRECTOR.TXT
as a reference.
∙ If you want your program to operate in some other
directory you should enter the text 'CD \SOMEDIRNAME'
on its on blank line.
∙ On another blank line add the name of the program to
execute. If the program is a batch file, the name of
the batch file must be preceded by the word 'CALL '
(note the trailing space). Therefore, 'CALL YOURBAT'.
If your program is a COM or EXE file, simply type
'YOURPROG'.
That's all there is to it - save the file and execute the
DIRECTOR with your preferred parameters.
As you can see, the options are quite diverse - you can change
DIRECTOR.BAT to suit any situation or menu requirement. The best
news of all is that the process is compatible with all programs,
performs very quickly and requires no resident memory - unless of
course you aren't already using ANSI.SYS which does require 4K of
resident memory (see file README).
BATMOUSE.COM and DIRECTOR.BAT are available through some BBS's
and the larger shareware distributors.
Nick Makris is a small business consultant and systems engineer
on the North Coast of California. For a 'no-nonsense', fully
registered version of BATMOUSE, the corresponding files and
current version of this documentation, send a check for $10.00
(including $1.00 P/H) to:
Startech Systems
BATMOUSE
PO BOX 1395
Gualala CA, 95445-1395
California residents add appropriate sales tax.